package happy.diandiankong.api.db;

import happy.diandiankong.api.model.Faces;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
import org.skife.jdbi.v2.sqlobject.mixins.Transactional;

import java.util.List;

/**
 * Title.
 * <p>
 * Description.
 *
 * @author Bill Lv {@literal <billcc.lv@hotmail.com>}
 * @version 1.0
 * @since 2016-10-30
 */
public interface FaceDao extends AutoCloseable, Transactional<FaceDao> {
    @SqlUpdate("INSERT INTO DDK_FACES (ID, UID, FACE_ID) VALUES (:ID, :UID, :FACE_ID)")
    void insert(@Bind("ID") Long id, @Bind("UID") Long uid, @Bind("FACE_ID") String faceId);

    @SqlQuery("SELECT ID, UID, FACE_ID FROM DDK_FACES WHERE UID = :UID AND FACE_ID = :FACE_ID")
    @Mapper(FaceMapper.class)
    Faces findByUidAndFaceId(@Bind("UID") Long uid, @Bind("FACE_ID") String faceId);

    @SqlQuery("SELECT ID, UID, FACE_ID FROM DDK_FACES WHERE UID = :UID")
    @Mapper(FaceMapper.class)
    List<Faces> findByUid(@Bind("UID") Long uid);

    @SqlQuery("SELECT ID, UID, FACE_ID FROM DDK_FACES")
    @Mapper(FaceMapper.class)
    List<Faces> findAll();
}
